package com.mianshi;

import java.util.*;


public class youzan {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param s string字符串
     * @return int整型
     */
    public int numDecodings (String s) {
        // write code here
        int n = s.length();
        s = " "+s;
        char[] arr = s.toCharArray();
        int[] f = new int[n+1];
        f[0] = 1;
        for(int i = 1; i <= n; i++){
            int a = arr[i] - '0';
            int b = (arr[i-1] - '0') * 10 + (arr[i] - '0');
            if(a >= 1 && a <= 9){
                f[i] = f[i-1];
            }
            if(b >= 10 && b <= 26){
                f[i] += f[i-2];
            }
        }
        return f[n];
    }


}